import request from '@/utils/request'
import { CommonSearch } from '@/config/list'
import { GrantList, GrantBeanData } from '@/model/system/privilege/GrantModel'

export function loadGrantTargetList (data: CommonSearch, targetType: string) {
  return request<GrantList>({
    url: '/starGrant/loadGrantTargetList?targetType=' + targetType,
    data: data,
    method: 'post'
  })
}

export function deleteData (id: string) {
  return request({
    url: `/starGrant/deleteGrantData?id=${id}`
  })
}

export function saveGrant (sourceId: string, targetType: string, data: GrantBeanData[]) {
  return request({
    url: '/starGrant/saveGrant?sourceId=' + sourceId + '&targetType=' + targetType,
    data: data,
    method: 'post'
  })
}

export function getSelectedGrant (fid: string, type: string) {
  return request({
    url: `/starGrant/getGrantData?fid=${fid}&type=${type}`
  })
}
